import * as tslib_1 from "tslib";
import { observable, action } from "mobx";
import request from "../utils/request";
import * as api from "../api/api";
import { LoadHoc, loading } from "../hoc/loadHoc";
let PointMallStore = class PointMallStore extends LoadHoc {
  constructor() {
    super(...arguments);
    /**
     * Banner
     */
    this.home = {};
    /**
     * 首页商品信息
     */
    this.allItemsInfo = {};
    /**
     * 商品详情
     */
    this.itemInfo = {};
    /**
     * 获取用户默认地址
     */
    this.userDefaultAddress = {};
    /**
     * 购买(下单)
     */
    this.orderDetail = {};
    /**
     * 订单列表
     */
    this.orders = {};
    /**
     * 订单详情
     */
    this.order = {};
    /**
     * 物流信息
     */
    this.orderLogistics = {};
    /**
     * 礼品定制列表
     */
    this.customizedInfo = {};
    /**
     * 礼品定制详情
     */
    this.customized = {};
  }
  async getHomeInfo(params) {
    const { callback } = params;
    const home = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetHomeAsync({}));
    this.home = home;
    callback && callback(home);
  }
  async getAllItemsInfo(params) {
    const { formRecommendCategoryId, pageIndex, pageSize, callback } = params;
    const allItemsInfo = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetAllItemsInfoAsync({
      formRecommendCategoryId,
      formSkipCount: (pageIndex - 1) * pageSize,
      formMaxResultCount: pageSize
    }));
    this.allItemsInfo = allItemsInfo;
    callback && callback(allItemsInfo);
  }
  async getItemInfo(params) {
    const { formId, callback } = params;
    const itemInfo = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetItemAsync({
      formId
    }));
    this.itemInfo = itemInfo;
    callback && callback(itemInfo);
  }
  async getUserDefaultAddress(params) {
    const { callback } = params;
    const userDefaultAddress = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetUserDefaultAddress({}));
    this.userDefaultAddress = userDefaultAddress;
    callback && callback(userDefaultAddress);
  }
  async placeOrder(params) {
    const { form, callback } = params;
    const orderDetail = await request(api.ApppointMallApiFetchParamCreactor.apppointMallBuyAsync({
      form
    }));
    this.orderDetail = orderDetail;
    callback && callback(orderDetail);
  }
  async getOrders(params) {
    const { formStatus, pageIndex, pageSize, callback } = params;
    const orders = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetOrdersAsync({
      formStatus,
      formSkipCount: (pageIndex - 1) * pageSize,
      formMaxResultCount: pageSize
    }));
    this.orders = orders;
    callback && callback(orders);
  }
  async getOrder(params) {
    const { formId, callback } = params;
    const order = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetOrderAsync({
      formId
    }));
    this.itemInfo = order;
    callback && callback(order);
  }
  /**
   * 修改未支付订单地址
   */
  async updateUserReceiver(params) {
    const { form, callback } = params;
    await request(api.ApppointMallApiFetchParamCreactor.apppointMallUpdateUserReceiverAsync({
      form
    }));
    callback && callback();
  }
  /**
   * 支付
   */
  async pay(params) {
    const { form, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallPayAsync({
      form
    }));
    callback && callback(res);
  }
  /**
   * 使用积分支付
   */
  async buyItemWithPoints(params) {
    const { form, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallBuyItemWithPointsAsync({
      form
    }));
    callback && callback(res);
  }
  /**
   * 取消订单
   */
  async cancelOrder(params) {
    const { form, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallCancelAsync({
      form
    }));
    callback && callback(res);
  }
  /**
   * 根据现有订单再下一单
   */
  async placeNewOrder(params) {
    const { id, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallNewOrderAsync({
      form: { id }
    }));
    callback && callback(res);
  }
  /**
   * 确认收货
   */
  async confirmGet(params) {
    const { form, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallConfirmGetAsync({
      form
    }));
    callback && callback(res);
  }
  /**
   * 删除订单
   */
  async deleteOrder(params) {
    const { form, callback } = params;
    const res = await request(api.ApppointMallApiFetchParamCreactor.apppointMallDeleteOrderAsync({
      form
    }));
    callback && callback(res);
  }
  async getOrderLogistics(params) {
    const { formId, callback } = params;
    const orderLogistics = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetOrderLogisticsAsync({
      formId
    }));
    this.orderLogistics = orderLogistics;
    callback && callback(orderLogistics);
  }
  /**
   * 礼品定制分类
   */
  async getAllCustomizedCategory(params) {
    const { callback } = params;
    const allCustomizedCategory = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetAllCustomizedCategoryAsync({}));
    callback && callback(allCustomizedCategory);
  }
  async getCustomizedInfo(params) {
    const { formCustomizedCategoryId, pageIndex, pageSize, callback } = params;
    const customizedInfo = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetCustomizedInfoAsync({
      formCustomizedCategoryId,
      formSkipCount: (pageIndex - 1) * pageSize,
      formMaxResultCount: pageSize
    }));
    this.customizedInfo = customizedInfo;
    callback && callback(customizedInfo);
  }
  async getCustomized(params) {
    const { formId, callback } = params;
    const customized = await request(api.ApppointMallApiFetchParamCreactor.apppointMallGetCustomizedAsync({
      formId
    }));
    this.customized = customized;
    callback && callback(customized);
  }
};
export { PointMallStore as default };

tslib_1.__decorate([observable], PointMallStore.prototype, "home", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getHomeInfo", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "allItemsInfo", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getAllItemsInfo", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "itemInfo", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getItemInfo", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "userDefaultAddress", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getUserDefaultAddress", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "orderDetail", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "placeOrder", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "orders", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getOrders", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "order", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getOrder", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "updateUserReceiver", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "pay", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "buyItemWithPoints", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "cancelOrder", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "placeNewOrder", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "confirmGet", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "deleteOrder", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "orderLogistics", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getOrderLogistics", null);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getAllCustomizedCategory", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "customizedInfo", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getCustomizedInfo", null);
tslib_1.__decorate([observable], PointMallStore.prototype, "customized", undefined);
tslib_1.__decorate([loading, action], PointMallStore.prototype, "getCustomized", null);